// 第三方。
import * as React from "react";
import * as ReactDOM from "react-dom";
// 公用。
import * as mvc from "common/mvc";
// 应用。
import * as dbtps from "../types";
import { BaseCommand } from "../base";
import ApplicationComponent from "../view/component/Application";
import ModelCommand from "./comandModel";
import ViewCommand from "./comandView";
import ControllerCommand from "./comandController";
/**
 * 初始化应用。
 */
export default class Initial extends BaseCommand<null, null> {
    public execute(): void {
        // 添加应用组件.
        ReactDOM.render(
            <ApplicationComponent/>,
            document.getElementById("application")
        );

        // 注册命令。
        // ==========================================================================================
        mvc.controller.register(dbtps.MNotificationType.None, ModelCommand);
        mvc.controller.register(dbtps.MNotificationType.ApplicationOpenDocument, ModelCommand);
        mvc.controller.register(dbtps.MNotificationType.ApplicationCloseDocument, ModelCommand);
        mvc.controller.register(dbtps.MNotificationType.ApplicationActiveDocumentChange, ModelCommand);
        // ==========================================================================================
        mvc.controller.register(dbtps.VNotificationType.None, ViewCommand);
        mvc.controller.register(dbtps.VNotificationType.NewDocument, ViewCommand);
        mvc.controller.register(dbtps.VNotificationType.HelpMenu, ViewCommand);
        // ==========================================================================================
        mvc.controller.register(dbtps.CNotificationType.None, ControllerCommand);
        mvc.controller.register(dbtps.CNotificationType.ApplicationStartup, ControllerCommand);
        mvc.controller.register(dbtps.CNotificationType.NewDocument, ControllerCommand);
        mvc.controller.register(dbtps.CNotificationType.OpenDocument, ControllerCommand);
        // ==========================================================================================

        // 启动应用。
        mvc.context.sendNotification(dbtps.CNotificationType.ApplicationStartup, null);
    }
}